package cn.offcn.controller;

import cn.offcn.entity.Dept;
import cn.offcn.service.DaptService;
import cn.offcn.utils.OAResult;
import cn.offcn.utils.TableVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author yuliantao
 * @create 2020 -09 -2020-09-21 19:10
 * @description 功能描述
 */
@Controller
@RequestMapping("/dept")
public class DaptController {

    @Autowired
    private DaptService daptService;
    @RequestMapping("/getDepts")
    @ResponseBody
    public TableVo<Dept> getDepts(int page, int limit){
        return daptService.getDepts(page,limit);
    }

    @ResponseBody
    @RequestMapping("/addDeprt")
    public OAResult addDeprt(Dept dept){
        return daptService.addDeprt(dept);
    }

    @RequestMapping("/deleteDept")
    @ResponseBody
    public  OAResult deleteDept(@RequestParam("deptnos[]") int [] deptnos){
        return daptService.deleteDept(deptnos);
    }
    @ResponseBody
    @RequestMapping("/getDeptByDeptno")
    public Dept getDeptByDeptno(int deptno){
      return  daptService.getDeptByDeptno(deptno);
    }
    @ResponseBody
    @RequestMapping("/updateDept")
    public OAResult updateDept(Dept dept){
        return daptService.updateDept(dept);
    }
}
